package cn.fsd.exception;

import cn.fsd.vo.ResultBean;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@ResponseBody
public class StoreroomExceptionHandler {

    @ExceptionHandler(value = {StoreroomException.class})
    @ResponseBody
    public <T> ResultBean<T> exceptionHandler(StoreroomException e){
        //这里先判断拦截到的异常是不是我们自己定义的异常类型
        return ResultBean.error(e.getCode(),e.getMsg());
    }

}
